package mysql

import "gorm.io/gorm"

type Product struct {
	gorm.Model
	Image  string  `gorm:"type:varchar(300)"`
	Title  string  `gorm:"type:varchar(30)"`
	Price  float64 `gorm:"type:decimal(10,2)"`
	Stock  int64   `gorm:"type:int(11)"`
	Summit string  `gorm:"type:varchar(300)"`
}

func (p *Product) FindProduct(db *gorm.DB, title string) (*Product, error) {
	err2 := db.Debug().Where("title=?", title).Find(p).Error
	return p, err2
}

func (p *Product) FindProductId(db *gorm.DB, id int64) (*Product, error) {
	err2 := db.Debug().Where("id=?", id).Find(p).Error
	return p, err2
}
